import { _decorator, Component, Node, Tween, v3, tween } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('TurkishTetrisGuidePanel')
export default class TurkishTetris_GuidePanel extends Component {
    static Instance: TurkishTetris_GuidePanel;
    @property(Node)
    hand: Node | null = null;
    //    // @property(Button)
    //    // Button_1: Button = null;
    //    // timer: number = 0;
    onLoad() {
        TurkishTetris_GuidePanel.Instance = this;
        this.ShowOn();
        this.ShowOff();
    }
    ShowOn() {
        this.node.active = true;
        this.AddListener();
        this.Refresh();
    }
    ShowOff() {
        this.node.active = false;
        this.RemoveListener();
    }
    Move_1() {
        this.hand.active = true;
        let pos = v3(80, -460, 0);
        this.hand.position = pos;

        Tween.stopAllByTarget(this.hand);
        const tween1 = tween(this.hand).repeatForever(
            tween()
                .by(1, { x: +200 })
                .delay(0.2)
                .call(() => {
                    this.hand.position = pos;
                })
        );
        tween1.start();
    }
    Move_2() {
        this.hand.active = true;
        let pos = v3(-130, -460, 0);
        this.hand.position = pos;

        Tween.stopAllByTarget(this.hand);
        const tween1 = tween(this.hand).repeatForever(
            tween()
                .by(1, { x: +170 })
                .delay(0.2)
                .call(() => {
                    this.hand.position = pos;
                })
        );
        tween1.start();
    }
    Refresh() {
        //        // this.Label_score.string = `得分：${GameData.GetScore()}`;
    }
    AddListener() {
        //        // this.Button_1.node.on("click", this.On_Button_1, this);
    }
    RemoveListener() {
        //        // this.Button_1.node.off("click", this.On_Button_1, this);
    }
    //    //
    On_Button_1() {
        // console.log(`On_Button_1`);

        //        // CardFunctions.Skill_1();
    }
    //    // update(dt: number): void {
    //    //     this.timer += dt;
    //    //     if (this.timer >= 0.06) {
    //    //         this.timer = 0;
    //    //         this.light.FlushProperties();
    //    //     }
    //    //     this.light.node.opacity -= 4;
    //    // }
    protected onDestroy(): void {
        this.hand.active = false;
    }
}

// /** 调试 */
window["TurkishTetris_GuidePanel"] = TurkishTetris_GuidePanel;